//
//  YFSearchBar.m
//  SJZ
//
//  Created by apple on 16/9/8.
//  Copyright © 2016年 智慧停车. All rights reserved.
//

#import "YFSearchBar.h"

@implementation YFSearchBar


- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{
    if(action == @selector(paste:)){
        return NO;
    }
    return [super canPerformAction:action withSender:sender];
}

// 控制左视图位置
- (CGRect)leftViewRectForBounds:(CGRect)bounds{
    
    CGFloat WH = 20;
    CGRect leftBounds = CGRectMake(bounds.origin.x + 10, (bounds.size.height - WH) / 2, WH, WH);
    return leftBounds;
}

// 控制右视图位置
- (CGRect)rightViewRectForBounds:(CGRect)bounds{
    
    CGRect rightBounds = CGRectMake(bounds.size.width - 26, (bounds.size.height - 18) / 2, 20, 20);
    return rightBounds;
}

// 控制显示文本的位置
- (CGRect)textRectForBounds:(CGRect)bounds
{
    CGRect textBounds = CGRectMake(bounds.origin.x + 10 + self.leftView.frame.size.width + 10, bounds.origin.y, bounds.size.width - self.leftView.frame.size.width * 2 - 40, bounds.size.height);
    return textBounds;
}

// 控制编辑文本的位置
-(CGRect)editingRectForBounds:(CGRect)bounds
{
    //return CGRectInset( bounds, 10 , 0 );
    CGRect edtingBounds = CGRectMake(bounds.origin.x + 10 + self.leftView.frame.size.width + 10, bounds.origin.y, bounds.size.width, bounds.size.height);
    
    return edtingBounds;
}

//- (void)setLeftView:(UIView *)leftView {
//    
//}

@end
